
package com.szpx.controller.ZJHController;

import com.szpx.entity.ZJH.DriverReservation;
import com.szpx.service.DriverReservationService;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import com.szpx.entity.ZJH.yueche;
import com.szpx.service.yuecheService;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 订单数据控制器
 */
@Controller
@CrossOrigin
@RequestMapping("/zjh")
public class ConfirmedController {

    @Autowired
    private DriverReservationService  driverReservationService;

    @RequestMapping("/confirmed/html")
    public String orderList(HttpSession session, Model model) {

        return "ZJH/confirmed.html";
    }


    @RequestMapping("/confirmed")
    @ResponseBody
    public Resp confirmed(@RequestBody DriverReservation driverReservation) {
        DriverReservation byId = driverReservationService.getById(driverReservation.getId());
        byId.setStatus(DriverReservation.STATUS_CONFIRMED);
        driverReservationService.update(byId);
        return Resp.success();
    }
    //拒接refuse
    @RequestMapping("/rejected")
    @ResponseBody
    public Resp rejected(@RequestBody DriverReservation driverReservation) {
        DriverReservation byId = driverReservationService.getById(driverReservation.getId());
        byId.setStatus(DriverReservation.STATUS_REJECTED);
        driverReservationService.update(byId);
        return Resp.success();
    }


}
